package com.example.hyw.szysteam.http;

import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Created by HYW on 2018/6/4.
 */

public class RetrofitManager {
    private ApiService retrofitApiService;

    private static class SingletonHolder{
        private final static RetrofitManager instance=new RetrofitManager();
    }

    public static RetrofitManager getInstance(){
        return SingletonHolder.instance;
    }

    public void init(){
        Retrofit retrofit=new Retrofit.Builder()
                .baseUrl("http://172.21.12.152:8080/")
                .addConverterFactory(GsonConverterFactory.create())
                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                .build();
        retrofitApiService=retrofit.create(ApiService.class);
    }

    public ApiService getRetrofitApiService(){
        init();
        return retrofitApiService;
    }
}
